% TEST_ID: LANG-EXPAND-0050
% CATEGORY: language/reflection
% 测试 varargin 变量

function test_varargin
    R1 = test_utils(1, 2); % Call with one output arguments
    assert(isequal(R1, 1));

    [R1, R2] = test_utils(2, 1); % Call with two output argument
    assert(isequal(R1, 2));
    assert(isequal(R2, 1));

    [R1, R2, R3] = test_utils(3,1,2); % Call with three output arguments
    assert(isequal(R1, 3));
    assert(isequal(R2, 1));
    assert(isequal(R3, 2));
end


function [R1,R2, R3] = test_utils(varargin)
    switch nargout
        case 0
        case 1
            R1 = varargin{1}; % Use the first element of varargin
        case 2
            R1 = varargin{1};
            R2 = varargin{2};
        case 3
            R1 = varargin{1};
            R2 = varargin{2};
            R3 = varargin{3};
        otherwise
            error('Too many output arguments');
    end
end

